﻿using System;
using System.Collections.Generic;
using System.Text;

using NGE;

namespace MH.MENU
{
    public class Sleep : Panelbox
    {
        public Sleep(Game g)
            : base(g)
        {
            Name = "旅店";

            Location = new Microsoft.DirectX.Vector3(120, 120, 0);
            Size = new System.Drawing.Size(80, 60);

            sleep0 = new Buttonbox();
            sleep0.Textbox.Text = "标准间";
            sleep0.Location = new Microsoft.DirectX.Vector3(0, 0, 0);
            sleep0.OnButtonboxEvent += new MenuEvent(sleep0_OnButtonboxEvent);

            sleep1 = new Buttonbox();
            sleep1.Textbox.Text = "舒适间";
            sleep1.Location = new Microsoft.DirectX.Vector3(0, 20, 0);
            sleep1.OnButtonboxEvent += new MenuEvent(sleep1_OnButtonboxEvent);

            sleep2 = new Buttonbox();
            sleep2.Textbox.Text = "豪华间";
            sleep2.Location = new Microsoft.DirectX.Vector3(0, 40, 0);
            sleep2.OnButtonboxEvent += new MenuEvent(sleep2_OnButtonboxEvent);

            AddElement(sleep0);
            AddElement(sleep1);
            AddElement(sleep2);

            this.OnPanelboxOpen += new MenuEvent(Sleep_OnPanelboxOpen);
            this.OnPanelboxClose += new MenuEvent(Sleep_OnPanelboxClose);
        }

        void Sleep_OnPanelboxClose(object sender, object arg)
        {
            scriptCOM.SetValue("menu_return", "0");
        }

        void Sleep_OnPanelboxOpen(object sender, object arg)
        {
            scriptCOM.SetValue("menu_return", "null");
        }

        void sleep0_OnButtonboxEvent(object sender, object arg)
        {
            ButtonboxState bs = (ButtonboxState)arg;
            if (bs == ButtonboxState.Up)
            {
                scriptCOM.AS("menu close", false);
                scriptCOM.AS("var menu_return 1", false);
            }
        }
        void sleep1_OnButtonboxEvent(object sender, object arg)
        {
            ButtonboxState bs = (ButtonboxState)arg;
            if (bs == ButtonboxState.Up)
            {
                scriptCOM.AS("menu close", false);
                scriptCOM.AS("var menu_return 2", false);
            }
        }
        void sleep2_OnButtonboxEvent(object sender, object arg)
        {
            ButtonboxState bs = (ButtonboxState)arg;
            if (bs == ButtonboxState.Up)
            {
                scriptCOM.AS("menu close", false);
                scriptCOM.AS("var menu_return 3", false);
            }
        }

        SceneComponent sceneCOM
        {
            get
            {
                return ((SceneComponent)game.GetComponent("SceneCOM"));
            }
        }
        ScriptComponent scriptCOM
        {
            get
            {
                return ((ScriptComponent)game.GetComponent("ScriptCOM"));
            }
        }

        Buttonbox sleep0;
        Buttonbox sleep1;
        Buttonbox sleep2;
    }
}
